<# # It is recommended to test the script on a local machine for its purpose and effects. # ManageEngine Endpoint Central will not be responsible for any # damage/loss to the data/setup based on the behavior of the script. # Description: Script is designed To remove the Local User Account via User SID # Arguments: User_SID # Example: S-1-5-21-475264420-3520914179-1595088936-1003 # Configuration Type - COMPUTER #> param ( [string]$SID ) if (-not $SID) { Write-Host "Please provide a SID as an argument." exit } $Profile = Get-WmiObject Win32_UserProfile | Where-Object { $_.SID -eq $SID } if ($Profile) { try { $Profile.Delete() Write-Host "User profile with SID $SID has been deleted." } catch { Write-Host "Failed to delete the user profile with SID $SID. Error: $_" } } else { Write-Host "No user profile found with SID $SID." }